package com.compty.paint.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.compty.security.domain.User;
import com.compty.security.domain.UserState;

/**
 * @Todo:顾客基本信息
 * @author: zhuqh
 * @CreateTime:2011-6-2 上午10:22:47
 */
@Entity
@Table(name = "t_customerinfo")
public class CustomerInfo implements java.io.Serializable{
	
	private static final long serialVersionUID = -4362092174282207585L;

	private Long id;
	
	private String userName;
	
	private String displayName;
	
	/************ 收货人姓名 ****************/
	private String customerName;
	
	/************ 密码 ****************/
	private String passwd;
	
	private String sex;
	
	/************ 身份证号码 ****************/
	private String idCard;
	
	/************ 固话 ****************/
	private String telphone;
	
	/************ 手机 ****************/
	private String mobile;
	
	/************ 邮箱 ****************/
	private String email;
	
	/************ 邮编 ****************/
	private String zipCode;
	
	/************ 街道地址 ****************/
	private String address;
	
	/************ 国家 ****************/
	private CountryInfo countryInfo;
	
	/************ 省份 ****************/
	private ProvinceInfo provinceInfo;
	
	/************ 城市 ****************/
	private CityInfo cityInfo;
	
	/************ 区县 ****************/
	private RegionInfo regionInfo;
	
	/************ 注册时间 ****************/
	private Date registerTime;
	
	/************ 注册状态 ****************/
	private UserState userState;
	
	/************ 预付金 ****************/
	private Double advance = 0d;
	
	private String pw_answer;

	private String pw_question;
	
	private String qq;
	
	private String msn;
	
	/************ 生日 ****************/
	private Date birthday;
	
	/************ 备注 ****************/
	private String remark;
	
	private User recommendUser;//推荐人

	@Id
	@GeneratedValue
	@Column(name = "id", unique = true, nullable = false)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	@Column(name = "customername", length = 100)
	public String getCustomerName() {
		return customerName;
	}

	public void setCustomerName(String customerName) {
		this.customerName = customerName;
	}

	@Column(name = "telphone", length = 40)
	public String getTelphone() {
		return telphone;
	}

	public void setTelphone(String telphone) {
		this.telphone = telphone;
	}

	@Column(name = "mobile", length = 40)
	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	@Column(name = "zipcode", length = 40)
	public String getZipCode() {
		return zipCode;
	}

	public void setZipCode(String zipCode) {
		this.zipCode = zipCode;
	}

	@Column(name = "address", length = 200)
	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="countryid")
	public CountryInfo getCountryInfo() {
		return countryInfo;
	}

	public void setCountryInfo(CountryInfo countryInfo) {
		this.countryInfo = countryInfo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="provinceid")
	public ProvinceInfo getProvinceInfo() {
		return provinceInfo;
	}

	public void setProvinceInfo(ProvinceInfo provinceInfo) {
		this.provinceInfo = provinceInfo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="cityid")
	public CityInfo getCityInfo() {
		return cityInfo;
	}

	public void setCityInfo(CityInfo cityInfo) {
		this.cityInfo = cityInfo;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="regionid")
	public RegionInfo getRegionInfo() {
		return regionInfo;
	}

	public void setRegionInfo(RegionInfo regionInfo) {
		this.regionInfo = regionInfo;
	}

	@Column(name = "email", length = 100)
	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Column(name = "username", length = 100)
	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	@Column(name = "passwd", length = 100)
	public String getPasswd() {
		return passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}

	@Column(name = "sex", length = 10)
	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	@Column(name = "id_card", length = 50)
	public String getIdCard() {
		return idCard;
	}

	public void setIdCard(String idCard) {
		this.idCard = idCard;
	}

	@Column(name = "register_time")
	public Date getRegisterTime() {
		return registerTime;
	}

	public void setRegisterTime(Date registerTime) {
		this.registerTime = registerTime;
	}

	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name="userstate_id")
	public UserState getUserState() {
		return userState;
	}

	public void setUserState(UserState userState) {
		this.userState = userState;
	}

	@Column(name = "advance")
	public Double getAdvance() {
		return advance;
	}

	public void setAdvance(Double advance) {
		this.advance = advance;
	}

	@Column(name = "pw_answer",length = 200)
	public String getPw_answer() {
		return pw_answer;
	}

	public void setPw_answer(String pwAnswer) {
		pw_answer = pwAnswer;
	}

	@Column(name = "pw_question",length = 200)
	public String getPw_question() {
		return pw_question;
	}

	public void setPw_question(String pwQuestion) {
		pw_question = pwQuestion;
	}

	@Column(name = "qq",length = 20)
	public String getQq() {
		return qq;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	@Column(name = "msn",length = 40)
	public String getMsn() {
		return msn;
	}

	public void setMsn(String msn) {
		this.msn = msn;
	}

	@Column(name = "birthday")
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	@Column(name = "remark",length = 200)
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name="recommend_userid")
	public User getRecommendUser() {
		return recommendUser;
	}

	public void setRecommendUser(User recommendUser) {
		this.recommendUser = recommendUser;
	}

	@Transient
	public String getDisplayName() {
		if( userName != null && userName.length() == 11){
			this.displayName = userName.substring(0,3)+"XXXX"+userName.substring(7);
		}else{
			this.displayName = userName;
		}
		return displayName;
	}

	public void setDisplayName(String displayName) {
		this.displayName = displayName;
	}
	
}
